/** create template */
String.prototype.renderTpl = function (obj) {
  var that = this
  var render = ''
  var source = this.toString()
  if (Object.prototype.toString.call(obj) === '[object Array]') {
    for (var i = 0; i < obj.length; i++) {
      render += that.renderTpl(obj[i])
    }
  } else if (typeof obj === 'object') {
    for (var i in obj) {
      if (typeof obj[i] !== 'function') {
        var patt = new RegExp("{{\\s*\\$" + i + "\\s*}}", "g")
        source = source.replace(patt, obj[i])
      }
    }
    render += source
  }
  return render
}
// render DOM about `parent dom` & `dom template` & `data`
function renderDom(dom, str, data) {
  dom.innerHTML = str.renderTpl(data)
}
// render list
function renderList(data) {
  var cellListDom = document.getElementById('cell-list')
  var str = 
  '<div class="cell clearfix has-hand">' + 
    '<img src="{{ $imgUrl }}" class="cell-img fl">' + 
    '<div class="cell-info fl">' + 
    ' <div class="cell-title brand-color text-overflow">{{ $name }}</div>' + 
    ' <div class="cell-desc text-overflow">{{ $desc }}</div>' + 
    ' <div class="cell-value"><span class="cell-gary">目的地: </span>{{ $address }}</div>' + 
    ' <div class="cell-bottom clearfix">' + 
    '  <div class="cell-bottom-item cell-score cell-gary fl"><span class="score brand-color">{{ $score }}</span>分</div>' + 
    '  <div class="cell-bottom-item cell-comment fl">{{ $comment }}条点评</div>' + 
    '  <div class="cell-bottom-item cell-sales fl"><span class="cell-gary">月销：</span>{{ $sales }}份</div>' + 
    ' </div>' + 
    '</div>' + 
    '<div class="cell-price fl brand-color"><span class="price">¥{{ $price }}</span>起</div>' + 
  '</div>'
  renderDom(cellListDom, str, data)
}